package com.mmm.station.activiti.controller;



import com.mmm.station.activiti.entity.SysLeave;
import com.mmm.station.activiti.service.SysLeaveService;
import com.mmm.station.base.controller.BaseController;
import com.mmm.station.base.entity.BaseResult;
import com.mmm.station.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.concurrent.TimeUnit;

/**
*
* @author: Code Generator
* @version:1.0
* @date:2016-10-17 10:55:12
* @description:用户Controller类，和界面交互
*/

@Controller
@RequestMapping(value = "sysLeave")
public class SysLeaveController extends BaseController {

    @Autowired
    private SysLeaveService sysLeaveService;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @RequestMapping(value = "getMyLeave",method = RequestMethod.POST)
    @ResponseBody
    public Object getMyLeave(HttpSession session){

        redisTemplate.opsForValue().set("dd",new User());
        session.setAttribute("aa","dsf");
        return  new BaseResult(true,sysLeaveService.selectList(new SysLeave()));
    }



    @RequestMapping(value = "setsession",method = RequestMethod.POST)
    @ResponseBody
    public Object setsession(HttpSession session){

        redisTemplate.opsForValue().set("dd",new User(),10, TimeUnit.SECONDS);
        session.setAttribute("aa","被你搞到了！！！！！！");
        return  session.getId();
    }



    @RequestMapping(value = "getmessage",method = RequestMethod.POST)
    @ResponseBody
    public Object getmessage(HttpSession session){


        return  session.getAttribute("aa");
    }



}